package com.wwlwxg.redis;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;

import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.StreamEntryID;

public class StreamPublish {

	static final String host = "10.92.35.24";
	static final int port = 6300;

	static Jedis jedis = new Jedis(host,port);

	public static void main(String[] args) throws Exception {
		try {
			Map<String, String> kv = new HashMap<String, String>();
			kv.put("a", "100"); // key -> a; value -> 100
			int index = 0;
			for(;;) {
				index++;
				if(index == 1000) {
					TimeUnit.SECONDS.sleep(10);
					index = 0;
				}
				jedis.xadd("MyStream", StreamEntryID.NEW_ENTRY, kv);

			}
		}finally {
			jedis.close();
		}
	}
}
